<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>naive</title>
    <link rel="stylesheet" href="../model/jsFn.css">
</head>
<body>
<div class="catalog">
    <h1>目录</h1>
    <ul>
        <li>
            <p><a href="#profile">naive</a></p>
            <ul>
                <li><p><a href="#jsFn_method">method</a></p></li>
                <li><p><a href="#jsFn_carry">carry</a></p></li>
                <li><p><a href="#jsFn_invoke">invoke</a></p></li>
            </ul>
        </li>
    </ul>
</div>
<div id="profile">
    <h2>对象简介:</h2>
    <p>分支管理</p>
</div>
<!--对象的某一个方法-->
<div class="jsFnModel" id="jsFn_method">
    <h3>method:</h3>
    <div class="shape">
        <h3>函数使用样式</h3>
        <p>naive.method(event,fn) -> null</p>
    </div>
    <div class="profile">
        <h3>函数功能简介</h3>
        <p>创建一个分支,名叫event</p>
    </div>
    <div class="version">
        <p>稳定性;2 - 稳定的</p>
        <p>新增于:v0.0.0</p>
    </div>
    <div class="params">
        <h3>参数列表:</h3>
        <ul>
            <li>
                <p>event</p>
                <p>&nbsp;string&nbsp;</p>
                <p>分支名称</p>
            </li>
            <li>
                <p>fn</p>
                <p>&nbsp;function&nbsp;</p>
                <p>分支执行的函数</p>
            </li>
        </ul>
    </div>
    <div class="res">
        <h3>返回值:</h3>
        <p>null</p>
    </div>
    <div class="code">
        <h3>例子</h3>
        <pre>
            <code>
                //服务端:
                context.naive.addLogic("test",async(ctx,pck)=>{
                    let naive = ctx.Naive();
                    naive.method("method1",async(ctx,pck)=>{
                        console.log('niahao');
                        return true;
                    });
                    naive.method("method2",async(ctx,pck)=>{
                        console.log('niahao2');
                        return false;
                    });
                    return {naive:naive.address}
                });
                //客服端:
                ServerAgent.invoke('test').then(res=>{
                    getAgent(res.naive).invoke('method1').then(res=>{
                        console.log(res);
                    });
                });
            </code>
        </pre>
    </div>
    <div class="error">
        <h3>抛出错误</h3>
    </div>
</div>
<div class="jsFnModel" id="jsFn_carry">
    <h3>carry:</h3>
    <div class="shape">
        <h3>函数使用样式</h3>
        <p>naive.carry(...events) -> promise</p>
    </div>
    <div class="profile">
        <h3>函数功能简介</h3>
        <p>监听events里任意一个子分支完成</p>
    </div>
    <div class="version">
        <p>稳定性;2 - 稳定的</p>
        <p>新增于:v0.0.0</p>
    </div>
    <div class="params">
        <h3>参数列表:</h3>
        <ul>
            <li>
                <p>events</p>
                <p>&nbsp;string&nbsp;</p>
                <p>分支名称</p>
            </li>
        </ul>
    </div>
    <div class="res">
        <h3>返回值:</h3>
        <p>object</p>
        <p>分支完成后的返回值</p>
    </div>
    <div class="code">
        <h3>例子</h3>
        <pre>
            <code>
                //服务端:
                context.naive.addLogic("test",async(ctx,pck)=>{
                    let naive = ctx.Naive();
                    naive.method("method1",async(ctx,pck)=>{
                        console.log('niahao');
                        return true;
                    });
                    naive.method("method2",async(ctx,pck)=>{
                        console.log('niahao2');
                        return false;
                    });
                    await ctx.invoker.interact('redirect',{url:'other.xml',naive:naive.address})
                    let data = await naive.carry(method1);
                    return true;
                });
                //客服端:
                //a.xml
                ServerAgent.invoke('test').then(res=>{
                    console.log('执行顺序2');
                    getAgent(res.naive).invoke('method2').then(res=>{
                        console.log('执行顺序3');
                    });
                });
                //other.xml
                getAgent.invoke(document.arguments.naive).invoke('method1').then(res=>{
                    console.log('执行顺序1');
                })
            </code>
        </pre>
    </div>
    <div class="error">
        <h3>抛出错误</h3>
    </div>
</div>
<div class="jsFnModel" id="jsFn_invoke">
    <h3>invoke:</h3>
    <div class="shape">
        <h3>函数使用样式</h3>
        <p>naive.invoke(event,[data]) -> promise</p>
    </div>
    <div class="profile">
        <h3>函数功能简介</h3>
        <p>服务端执行一个分支</p>
    </div>
    <div class="version">
        <p>稳定性;2 - 稳定的</p>
        <p>新增于:v0.0.0</p>
    </div>
    <div class="params">
        <h3>参数列表:</h3>
        <ul>
            <li>
                <p>event</p>
                <p>&nbsp;string&nbsp;</p>
                <p>分支名称</p>
            </li>
            <li>
                <p>data</p>
                <p>&nbsp;object&nbsp;</p>
                <p>分支执行时所需参数</p>
            </li>
        </ul>
    </div>
    <div class="res">
        <h3>返回值:</h3>
        <p>promise</p>
        <p>无</p>
    </div>
    <div class="code">
        <h3>例子</h3>
        <pre>
            <code>
                context.naive.addLogic("test",async(ctx,pck)=>{
                    let naive = ctx.Naive();
                    naive.method("timeout",async(ctx,pck)=>{
                        console.log('niahao');
                        return true;
                    });
                    naive.method("pay",async(ctx,pck)=>{
                        console.log('niahao2');
                        return false;
                    });
                    ctx.invoker.interact('finish',{});
                    let timeout = setTimeout(()=>{
                        naive.invoke(timeout)
                    },15*60*1000);
                    let isPay = await naive.carry("timeout","pay");
                    clearTimeout(timeout);
                    return isPay;
                });
            </code>
        </pre>
    </div>
    <div class="error">
        <h3>抛出错误</h3>
    </div>
</div>
<div class="author"><p>by-草草</p></div>
</body>
</html>